package com.wn.pettyloan.service.impl;

import com.wn.pettyloan.dto.DebitDto;
import com.wn.pettyloan.entity.Debit;
import com.wn.pettyloan.mapper.DebitMapper;
import com.wn.pettyloan.service.DebitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;


@Service
public class DebitServiceImpl implements DebitService {

    @Resource
    private DebitMapper debitMapper;

    @Override
    public void updateStatusById(Integer debitId, int status) {
        Debit debit = new Debit();
        debit.setDebitId(debitId);
        debit.setDebitStatus(status);
        debitMapper.updateByPrimaryKeySelective(debit);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insertSelective(Debit record) {
        //10 未初审信息
        record.setDebitStatus(10);
        return debitMapper.insertSelective(record);
    }

    @Override
    public Debit selectByPrimaryKey(Long id) {
        System.out.println("");
        return debitMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Debit record) {
        return debitMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int insert(Debit debit) {
        return debitMapper.insert(debit);
    }

    @Override
    public int updateApproveNumById(Integer debitId, BigDecimal checkFee) {
        Debit debit = new Debit();
        debit.setDebitId(debitId);
        debit.setDebitApproveLimit(checkFee);
        return debitMapper.updateByPrimaryKeySelective(debit);
    }

    @Override
    public List<Debit> findByDto(DebitDto debitDto) {
        return debitMapper.selectByDto(debitDto);
    }

}